﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Rotempco.ORM.Generator.Objects;
using Rotempco.ORM.Generator.Logic;

namespace Rotempco.ORM.Generator.ViewModels
{
    public class VMColumns
    {
        #region [ Singleton Constructor ]

        static readonly VMColumns _Instance = new VMColumns();

        static VMColumns()
        {
        }

        private VMColumns()
        {
            Columns = new ObservableCollection<DatabaseColumn>();
        }

        public static VMColumns Instance
        {
            get
            {
                return _Instance;
            }
        }

        public static VMColumns GetInstance()
        {
            return Instance;
        }

        #endregion

        public ObservableCollection<DatabaseColumn> Columns { get; private set; }

        public void LoadAll(RotempcoSettings rotempcoSettings, string tableName)
        {
            Columns.Clear();
            ColumnSettingsLogic.GetColumnsWithSettings(rotempcoSettings, tableName).ForEach(d => Columns.Add(d));
        }
    }
}
